package com.yiquan.search.config;

import com.yiquan.search.interceptor.HotSearchInterceptor;
import com.yiquan.search.interceptor.LogInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author Tyrone
 * @date 2022/3/7 21:17
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    @Autowired
    private LogInterceptor logInterceptor;

    @Autowired
    private HotSearchInterceptor hotSearchInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(logInterceptor).addPathPatterns("/**");
        registry.addInterceptor(hotSearchInterceptor).addPathPatterns("/search/**").excludePathPatterns("/search/getHotSearch");
    }
}
